<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>欢迎页</title>
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
    <script type="text/javascript" src="../js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="../laydate/laydate.js"></script>
    <script src="../js/city-picker.data.js"></script>
    <script src="../js/city-picker.js"></script>
    <script src="../js/publicJS.js"></script>
    <style>
        .city-picker-span {
            width: 300px;
        }
    </style>
</head>

<body style="background:#328f46">
<div class="headiv">
    <div class="logotag">
        <a class="logo"><img src="../img/logo.png" width="440" height="65"></a>
        <b class="line"></b>
    </div>
    <a class="username">欢迎登录：<i id="name"></i></a>
    <span class="btnbox">
    	<a class="update" href="/updatePerson" title="修改"></a><a class="exit" href="/logout" title="退出"></a>
    </span>
    <div class="clear" style="height:20px; background:#328f46"></div>
</div>

<div class="messagebox">
    <div class="messageleft">
        <ul class="Fstage">
            <shiro:hasRole name="normalUser">
                <li><a href="#"><em class="e3"></em>健康信息管理
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/healthInfoAdd">健康信息录入</a></li>
                        <li><a href="/healthInfoSelect">健康指数查询</a></li>
                    </ul>
                </li>
                <li><a href="#"><em class="e3"></em>运动信息管理
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/sportIndex">运动信息录入</a></li>
                        <li><a href="/sportIndexSelect">运动信息查询</a></li>
                    </ul>
                </li>
                <li><a href="#"><em class="e3"></em>心理测试
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/testPage">开始测试</a></li>
                        <li><a href="/testrecord">测试记录</a></li>
                    </ul>
                </li>
                <li><a href="#"><em class="e3"></em>健康新闻
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/healthnewsPage">健康新闻</a></li>
                    </ul>
                </li>
            </shiro:hasRole>

            <shiro:hasRole name="admin">
                <li><a href="#"><em class="e3"></em>用户管理
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/userManagement">用户管理</a></li>
                        <li><a href="/userManageSelect">查询所有用户</a></li>
                    </ul>
                </li>
                <li><a href="#"><em class="e3"></em>发布新闻
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/releaseNewsPage">发布新闻</a></li>
                    </ul>
                </li>
            </shiro:hasRole>
        </ul>
    </div>
    <!--****************以上不能动，页面固定的东西************************-->
    <div class="messageright">
        <div class="formpage">
            <div class="clear" style="height:20px"></div>
            <h2>健康信息修改</h2>
            <div class="clear" style="height:30px"></div>

            <span class="information">
            	<div class="clear" style="height:10px"></div>
                <!--<a class="headpic1" href="#"><img src="/img/sm_headpic.jpg"></a>-->
                <form>
                    <table>
                        <tr>
                            <td>选择日期：</td>
                            <td>
                               <input class="textput" type="text" id="input1" value=""/>
                            </td>
                            </tr>
                        <tr>
                            <td>登录帐号：</td>
                            <td colspan="2"></td></tr>
                        <tr>
                            <td>身&nbsp;&nbsp;高：</td>
                            <td><input class="textput" id="height" type="text"/></td>
                            <td><p class="wrrong">cm</p></td></tr>
                        <tr>
                            <td>体&nbsp;&nbsp;重：</td>
                            <td><input class="textput" id="weight" type="text"/></td>
                            <td><p class="wrrong">Kg</p></td>
                        </tr>
                        <tr>
                            <td>饮食情况：</td>
                            <td>
                                <label>&nbsp;多<input name="diet" type="radio" value="多"></label>
                                <label>适中<input name="diet" type="radio" value="适中"></label>
                                <label>&nbsp;少<input name="diet" type="radio" value="少"></label>
                            </td>
                            <td><p class="wrrong">*此处不能为空</p></td>
                        </tr>
                        <tr>
                            <td>血&nbsp;&nbsp;压：</td>
                            <td><input class="textput" id="BP" type="text"/></td>
                            <td><p class="wrrong"></p></td>
                        </tr>
                        <tr>
                            <td>睡眠质量：</td>
                            <td>
                                <label>高<input name="SQ" type="radio" value="高"></label>
                                <label>中<input name="SQ" type="radio" value="中"></label>
                                <label>低<input name="SQ" type="radio" value="低"></label>
                            </td>
                            <td><p class="wrrong">*此处不能为空</p></td>
                        </tr>
                        <tr>
                            <td></td>
                            <td colspan="2"><a class="greenbtn" href="#" id="btn" onclick="">提交信息</a></td>
                        </tr>
                    </table>
                </form>
                <div class="clear"></div>
            </span>
            <div class="clear" style="height:50px"></div>


        </div>
    </div>
    <div class="clearh" style="height:0"></div>
</div>

</body>
</html>
<script>
    //时间日期控件
    laydate.render({
        elem: '#input1'
        , type: 'datetime'
    });
    $(".Fstage>li").click(function () {
        if ($(this).children("ul").hasClass("Tstage"))
            $(this).siblings("li").children("ul").hide();
        $(this).children("ul").slideDown();
    });
    showModifyData();

    //显示
    function showModifyData() {
        $.ajax({
            url:"/seleHealth_info",
            type:"post",
            success:function (result) {
                if (result.code == 1){
                    console.log(result);

                    callbackInfo(result)
                }else {
                    alert(result.msg);
                }
            }
        });
    }
    //回显
    function callbackInfo(result) {
        $("#input1").val(result.);
        $("#height").val(result.);
        $("input[name='diet']:checked").val(result.);
        $("#BP").val(result.);
        $("input[name='SQ']:checked").val(result.);
    }
    //健康信息修改
    $("#btn").click(function () {
        $.ajax({
            url: "/modify_info",
            type: "post",
            data: {
                time: $("#input1").val(),
                height: $("#height").val(),
                weight: $("#weight").val(),
                diet: $("input[name='diet']:checked").val(),
                BP: $("#BP").val(),
                SQ: $("input[name='SQ']:checked").val()
            },
            success: function (result) {
                alert(result.msg);
                window.location.href = window.location.href;
            }
        });
    });
</script>
